[20250314] BOJ / G4 / 두 대표 자연수 / 권혁준 #247
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://www.acmicpc.net/problem/2551
🧭 풀이 시간
12분
👀 체감 난이도
✏️ 문제 설명
1이상 10000이하의 자연수 N개가 주어진다.
이 자연수들의 대표 자연수에는 두 가지 유형이 있다.
두 유형에 대한 대표 자연수를 구해보자.
🔍 풀이 방법
[사용한 알고리즘]
수의 개수 N은 최대 5000000이지만, 수의 종류는 10000가지밖에 없다.
대표 자연수가 될 수 있는 수의 범위 역시 1 ~ 10000이니까 이 범위에서 10000 * 10000으로 완탐을 돌려서 답을 구할 수 있다.
⏳ 회고
유형 1은 완탐 말고도 정렬로 중앙값을 찾아서 풀 수 있는데,
유형 2를 풀 방법이 달리 생각이 나질 않아서 비둘기집으로 풀었다.